import request from '@/utils/request'

export function getUserCenter(header?: any) {
    return request.get({ url: '/user/center', header }, { ignoreCancel: true })
}

// 个人信息
export function getUserInfo() {
    return request.get({ url: '/user/info' }, { isAuth: true })
}

// 个人编辑
export function userEdit(data: any) {
    return request.post({ url: '/user/setInfo', data }, { isAuth: true })
}

// 绑定手机
export function userBindMobile(data: any, header?: any) {
    return request.post({ url: '/user/bindMobile', data, header }, { isAuth: true })
}

// 微信电话
export function userMnpMobile(data: any) {
    return request.post({ url: '/user/getMobileByMnp', data }, { isAuth: true })
}

// 更改手机号
export function userChangePwd(data: any) {
    return request.post({ url: '/user/changePassword', data }, { isAuth: true })
}

//忘记密码
export function forgotPassword(data: Record<string, any>) {
    return request.post({ url: '/user/resetPassword', data })
}

//余额明细
export function accountLog(data: any) {
    return request.get({ url: '/account_log/lists', data })
}

export function getTravelerList() {
    return request.get({ url: '/travelers/all' })
}

/**
 * @description 添加出行人
 */
export function addTraveler(data: any) {
    return request.post({ url: '/travelers/add', data: data }, { isAuth: true })
}

/**
 * @description 修改出行人
 */
export function editTraveler(data: any) {
    return request.post({ url: '/travelers/edit', data: data }, { isAuth: true })
}

/**
 * @description 删除出行人
 */
export function delTraveler(data: { id: number }) {
    return request.post({ url: '/travelers/del', data: data }, { isAuth: true })
}



/**
 * @description 加入购物车
 * @return { Promise }
 */
export function addCart(data: any) {
    return request.post({ url: '/cart/add', data: data }, { isAuth: true })
}

/**
 * @description 删除购物车
 * @param { number } id
 * @return { Promise }
 */
export function cancelCart(data: { id: number }) {
    return request.post({ url: '/cart/cancelCart', data: data }, { isAuth: true })
}

/**
 * @description 获取购物车列表
 * @return { Promise }
 */
export function getCartList() {
    return request.get({ url: '/cart/lists' })
}
